
function finish(scheduleId,action){
    $(".audit").attr("disabled",true);
    if(confirm("你确认该排期已走货完成？")){
        $.ajax({
            url:appRoot + "/schedule/finish/" + scheduleId,
            type:'post',
            dataType:'json',
            success:function(msg){
                if(msg.result){
                    window.location.href= appRoot + '/schedule/'+ action + '?message=' + encodeURIComponent('操作成功');
                }else{
                    showMessage("操作失败");
                    $(".audit").attr("disabled",false);
                }
            }
       });
    }else{
        $(".audit").attr("disabled",false);
    }
}
currentPurchaseId = null;
$(function() {
	$("#supplierId").change(function(){
	    $(this).click();
	});
});

function importSchedule(){
    if(confirm("需要导入明细数据并设置初始值吗？")){
        $("#notice").html("数据导入中...").show();
         $.ajax({
             url:appRoot + "/purchaseItem/importToSchedule?purchaseIds=" + $("#supplierId").val() + "&date=" + (new Date().valueOf()),
             type:'post',
             data: $("#settingForm").serializeArray(),
             dataType:'json',
             success:function(msg){
                 if(msg.result>0){
                     window.location.href= appRoot + '/schedule/page?message=' + encodeURIComponent("成功导入" + msg.result + "条订单明细");
                 }else{
                     $("#notice").html("没有新的明细需导入");
                 }
             }
        });
    }
}